import DApp from '../config/configuration.js';
import BigNumber from "bignumber.js";
import detectEthereumProvider from "@metamask/detect-provider";
import { ethers } from "ethers";
import store from '@/utils/store.js'
const API = {
	async swapJDCC() {
		let {
			swapJDCC
		} = this.meta;
		let {
			account
		} = this;
		return new Promise((resolve, reject) => {
			swapJDCC().then(res => {
				resolve(res)
			}).catch(err => {
				uni.hideLoading();
				reject(err)
			})
		});
	},
	async swapJDCCLP() {
		let {
			swapJDCCLP
		} = this.meta;
		let {
			account
		} = this;
		return new Promise((resolve, reject) => {
			swapJDCCLP().then(res => {
				resolve(res)
			}).catch(err => {
				uni.hideLoading();
				reject(err)
			})
		});
	},
}

export default {
	meta: null,
	account: null,
	web3: null,
	async init(coin) {
		let obj = await DApp.erc20Init(coin);
		let {
			meta,
			account,
			web3
		} = obj;
		this.meta = meta;
		this.account = account;
		this.web3 = web3;
		return this;
	},
	...API
}